package br.com.lh.urabuilder.domain.xml
{
	import mx.collections.ArrayCollection;
	
	public class ConditionalAction extends BaseAction
	{
		
		protected var optionList:ArrayCollection = new ArrayCollection();
		
		public function addOption(option:Option):void{
			optionList.addItem(option);
		}
		
		public function clearOptions():void{
			optionList.removeAll();
		}
		
		public function removeOption(option:Option):void{
			var index:int = optionList.getItemIndex(option);
			optionList.removeItemAt(index);
		}
		
		public function getOptions():ArrayCollection{
			return optionList;
		}
		
		override public function xmlName():String{
			return "Conditional";
		}
		
		override public function toolTipText():String{
			return "Chooses an operation based on the input value";
		}
			
		public function ConditionalAction()
		{
		}
		
		override public function toXML(includeNullable:Boolean):XML{
			var newXmlRow:XML= <Conditional></Conditional>
			super.buildXml(newXmlRow,includeNullable);
			for each (var option:Option in optionList){
				if (option !=null){
					newXmlRow.appendChild(option.toXML);
				}
			}
			return newXmlRow;
		}

	}
}